import { reqAddressInfo, reqOrderInfo } from '@/api'

const state = {
    addressInfo:[],
    orderInfo:{}
}
const actions = {
    //获取用户地址信息
    async getAddressInfo({commit}) {
        let res = await reqAddressInfo()
        // console.log(res);
        if(res.code == 200) {
            commit('GETADDRESSINFO', res.data)
        }
    },
    //获取商品清单
    async getOrderInfo({commit}) {
        let res = await reqOrderInfo()
        if(res.code == 200) {
            commit('GETORDERINFO',res.data)
        }
    }
} 
const mutations = {
    GETADDRESSINFO(state, address) {
        state.addressInfo = address
    },
    GETORDERINFO(state, orderInfo) {
        state.orderInfo = orderInfo
    }
}
const getters = {}

export default {
    state,
    actions,
    mutations,
    getters
}